<?php

include_once($_SERVER["DOCUMENT_ROOT"]. "/core/inc.php");
include_once($_SERVER['DOCUMENT_ROOT'] ."/config/city_config.php");

$g_cgival = array();
$g_show = array();
$g_pro = array();
if(! security_check::check_refer())
{
	throw new Exception("来路不明");
}


function check_cgi_pro()
{
	global $g_cgival, $g_show, $g_pro;
	cgi::both($g_cgival['t'],"t","json");
	$g_cgival['t'] = string::un_html($g_cgival['t']);

	cgi::both($g_cgival['callback'],"callback","");
	$g_cgival['callback'] = string::un_html($g_cgival['callback']);
	
	cgi::both($g_cgival['id'],"id","");
	$g_cgival['id'] = intval($g_cgival['id']);
	

		
	
}


function get_data()
{
	global $g_cgival, $g_show, $g_pro,$config;
	
	$g_show["list"] = $config['city'][$g_cgival['id']];
	
	$html= "<option value=''>请选择</option>";
	foreach($g_show["list"] as $key => $value)
	{
		$html .="<option value='{$key}'>{$value}</option>";
	
	}
	
	$g_show["list_html"] = $html;

}

 
try
{
	check_cgi_pro();
	get_data();

	$g_show["error"] = "0";
	$g_show["errmsg"] = "";
}
catch (Exception $e)
{
	$g_show["error"] = "1";
	$g_show["errmsg"] = $e->getMessage();
}
show_pro();
exit();


function show_pro()
{
	global $g_cgival, $g_show, $g_pro;
	

	if($g_cgival['cb'])
	{
		header("Location:".$g_cgival['cb']."?pic_source={$g_show["pic_path"]}&pic={$g_show["pic_path1"]}&pic_name={$g_show["pic_name"]}&size={$g_show["size"]}&form_id={$g_show["form_id"]}&error={$g_show["error"]}&errormsg=".urlencode($g_show["errmsg"]));
	}
	else 
	{
		echo output::json($g_cgival["t"], $g_show, $g_cgival["callback"]);
	}
}